package com.wqtz.chechai.view.activities;
import android.content.Intent;
import android.graphics.Rect;
import android.os.Bundle;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.wqtz.chechai.R;
import com.wqtz.chechai.adapter.ProvinceSortAdapter;
import com.wqtz.chechai.base.BaseActivity;
import com.wqtz.chechai.bean.ProviceShort;
import com.wqtz.chechai.presenter.BasePresent;
import com.wqtz.chechai.utils.FileUtils;
import com.wqtz.chechai.utils.JsonUtils;
import com.wqtz.chechai.utils.ToastUtils;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
/**
 * 项目名称： CheChai
 * 创建人 : Liberation
 * 创建时间: 2017/2/7 16:02
 */
public class ProVinceSortActivity extends BaseActivity implements ProvinceSortAdapter.callBack {
	@BindView(R.id.iv_back)
	ImageView mIvBack;
	@BindView(R.id.tv_title)
	TextView mTvTitle;
	@BindView(R.id.top)
	RelativeLayout mTop;
	@BindView(R.id.rv)
	RecyclerView mRecyclerView;
	ProvinceSortAdapter mProvinceSortAdapter;
	ProviceShort mProviceShort;
	List<ProviceShort.ResultBean.AreaListBean> datas;
	@Override
	public void init() {
		ButterKnife.bind(this);
		datas = new ArrayList<>();
		mProviceShort=JsonUtils.getProvinceSort(FileUtils.getJson(this,"Provicesort.json"));
		datas.addAll(mProviceShort.getResult().getArea_list());
		mProvinceSortAdapter = new ProvinceSortAdapter(R.layout.item_area,datas);
		mRecyclerView.setLayoutManager(new GridLayoutManager(this,1));
		mRecyclerView.setAdapter(mProvinceSortAdapter);
		mProvinceSortAdapter.setOnItemClick(this);
	}
	@Override
	public void loadData() {
	}
	@Override
	public int setContentViews() {
		return R.layout.activity_provicesort;
	}
	@Override
	public BasePresent createPresenter() {
		return null;
	}
	@OnClick(R.id.iv_back)
	public void onClick() {
		finish();
	}
	@Override
	public void getSortCallBack(String sort, int position) {
		Intent intent = new Intent();
		intent.putExtra("sort",sort);
		setResult(RESULT_OK,intent);
		finish();
	}
	@Override
	protected void onResume() {
		super.onResume();
		activitys.add(this); //添加当前的activity
	}
}